package com.shao.im.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shao.im.entity.FriendsRelations;
import com.shao.im.entity.vo.FriendsListVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 好友关系表(FriendsRelations)表数据库访问层
 *
 * @author makejava
 * @since 2023-07-28 16:59:40
 */
public interface FriendsRelationsDao extends BaseMapper<FriendsRelations> {

    @Select("""
     select u.id, if(fr.beizhu = "", u.nickname, fr.beizhu) as name, u.header as img
                from friends_relations fr
                join user u on fr.fid = u.id
                where fr.uid = #{uid}
    """)
    List<FriendsListVo> queryFriendsListByMe(Integer uid);

    @Select("""
        select fid from friends_relations where uid = #{uid}
    """)
    List<Integer> queryFidListByMe(Integer uid);
}

